Function IF
Example (if the visitor use Opera Mini, he/she will see the warning, other doesn't.):
Code : <script type="text/javascript">
x=(navigator.appName);
if (x=="Opera") { document.write("we detect that you are using <b>Opera Mini</b>, you need to press Menu » Tools » Setting » uncheck \"Mobile View\" » OK (then reload/refresh) in order to view the optimized design for your browser."); }
else
{
document.write("Your browser is not Opera Mini"); }
</script>
Say Greeting
Example (Write a "Good morning" greeting if the time is less than 10) :
Code : <script type="text/javascript">
var d=new Date();
var time=d.getHours();
if (time<10)
{
document.write("<b>Good morning</b>");
}
</script>
Say Greeting 2
Example (If the time is less than 10, you will get a "Good morning" greeting. Otherwise you will get a "Good day" greeting.) :
Code : <script type="text/javascript">
var d = new Date();
var time = d.getHours();
if (time < 10)
{
document.write("Good morning!");
}
else
{
document.write("Good day!");
}
</script>
Say Greeting 3
Example :
Code : <script type="text/javascript">
var d = new Date()
var time = d.getHours()
if (time<10)
{
document.write("<b>Good morning</b>");
}
else if (time>10 && time<16)
{
document.write("<b>Good day</b>");
}
else
{
document.write("<b>Hello World!</b>");
}
</script>